gtkscrolledwindow: Consider shift key presses when decelerating
authorSebastian Keller <sebastian-keller@gmx.de>
Sat, 4 Aug 2018 14:24:33 +0000 (16:24 +0200)
committerSebastian Keller <sebastian-keller@gmx.de>
Sat, 4 Aug 2018 14:24:33 +0000 (16:24 +0200)
Otherwise horizontal scrolling using the shift key would decelerate
vertically.

Fixes https://gitlab.gnome.org/GNOME/gtk/issues/770

gtk/gtkscrolledwindow.c

index 90d7b2fdfe473c7ea5a05580292916df42a1bb1d..68e048c929ba83b40d6389b58e099b3a4f4bd7a0 100644 (file)
@@ -1341,12 +1341,29 @@ scroll_controller_decelerate (GtkEventControllerScroll *scroll,
                               GtkScrolledWindow        *scrolled_window)
 {
   gdouble unit_x, unit_y;
+  gboolean shifted;
+  GdkModifierType state;
+
+  if (!gtk_get_current_event_state (&state))
+    return;
+
+  shifted = (state & GDK_SHIFT_MASK) != 0;
 
   unit_x = get_scroll_unit (scrolled_window, GTK_ORIENTATION_HORIZONTAL);
   unit_y = get_scroll_unit (scrolled_window, GTK_ORIENTATION_VERTICAL);
-  gtk_scrolled_window_decelerate (scrolled_window,
-                                  initial_vel_x * unit_x,
-                                  initial_vel_y * unit_y);
+
+  if (shifted)
+    {
+      gtk_scrolled_window_decelerate (scrolled_window,
+                                      initial_vel_y * unit_x,
+                                      initial_vel_x * unit_y);
+    }
+  else
+    {
+      gtk_scrolled_window_decelerate (scrolled_window,
+                                      initial_vel_x * unit_x,
+                                      initial_vel_y * unit_y);
+    }
 }
 
 static void